home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / configure < prev    next >
Text File  |  1994-08-01  |  40KB  |  1,381 lines

  1. #!/bin/sh
  2. #    $Header: /usr/people/sam/fax/RCS/configure,v 1.145 1994/04/27 21:55:13 sam Rel $
  3. #
  4. # FlexFAX Facsimile Software
  5. #
  6. # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler
  7. # Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
  8. # Permission to use, copy, modify, distribute, and sell this software and 
  9. # its documentation for any purpose is hereby granted without fee, provided
  10. # that (i) the above copyright notices and this permission notice appear in
  11. # all copies of the software and related documentation, and (ii) the names of
  12. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  13. # publicity relating to the software without the specific, prior written
  14. # permission of Sam Leffler and Silicon Graphics.
  15. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  19. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  22. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  23. # OF THIS SOFTWARE.
  24. #
  25.  
  26. # Configuration script for FlexFAX
  27.  
  28. #
  29. # Shell script to setup machine-dependent files in
  30. # preparation for building flexfax source.
  31. #
  32. RM="rm -f"
  33. CP="cp"
  34.  
  35. PATH=/bin:/usr/bin:/etc
  36. test -d /usr/ccs/bin && PATH=$PATH:/usr/ccs/bin        # SVR4/Solaris2
  37. test -d /usr/sbin && PATH=$PATH:/usr/sbin        # SGI and others
  38. test -d /usr/bsd && PATH=$PATH:/usr/bsd            # SGI
  39. test -d /usr/ucb && PATH=$PATH:/usr/ucb            # Sun and others
  40. test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc    # Sun and others
  41.  
  42. applyEdits()
  43. {
  44.     file=$1; shift
  45.     (for i do
  46.     echo "$i";
  47.      done; echo w; echo q) | ed - $file >/dev/null
  48. }
  49.  
  50. #
  51. # Apply a set of ed commands to a file.  If the
  52. # file is initially setup read-only, then it is
  53. # made writeable, edited, and then read-only again.
  54. #
  55. editFile()
  56. {
  57.     file=$1;
  58.     if [ ! -w $file ]; then
  59.     chmod +w $file
  60.     applyEdits "$@"
  61.     chmod -w $file
  62.     else
  63.     applyEdits "$@"
  64.     fi
  65. }
  66.  
  67. #
  68. # Like editFile, but first save the original
  69. # as file.orig, a la the patch program.
  70. #
  71. patchFile()
  72. {
  73.     file=$1;
  74.     $RM $file.orig; $CP $file $file.orig
  75.     if [ ! -w $file ]; then
  76.     chmod +w $file
  77.     applyEdits "$@"
  78.     chmod -w $file
  79.     else
  80.     applyEdits "$@"
  81.     fi
  82. }
  83.  
  84. identifyTarget()
  85. {
  86.     random=`date | awk '{print $4}' | sed -e 's/.*://'` 2>/dev/null
  87.     case "$random" in
  88.     1*)    echo "Wow, you've got a $1 system!";;
  89.     2*)    echo "Hmm, looks like a $1 system.";;
  90.     3*)    echo "Oh no, not another $1 system...";;
  91.     4*)    echo "Well I'll be, a $1 system.";;
  92.     5*)    echo "Fee, fie, foe, this smells like a $1 system.";;
  93.     *)    echo "Gosh, aren't you lucky to have a $1 system!";;
  94.     esac
  95. }
  96.  
  97. checkStrings()
  98. {
  99.     f=$1; shift
  100.     strings $f | grep "$@" >/dev/null 2>&1
  101.     return
  102. }
  103.  
  104. #
  105. # If no target is specified, try to deduce the system.
  106. #
  107. TARGET=$1
  108. if [ -z "$TARGET" ]; then
  109.     SYS=`uname -s` 2>/dev/null
  110.     case @"$SYS" in
  111.     @IRIX)    TARGET=sgi;;
  112.     @UNIX_SV)    TARGET=svr4;;
  113.     @Linux)    TARGET=linux;;
  114.     @SunOS)    if [ -d /etc/saf ]; then
  115.             TARGET=solaris2 SYS="Solaris 2.x"
  116.         else
  117.             TARGET=sun4
  118.         fi
  119.         ;;
  120.     @BSD/386)    TARGET=bsdi;;
  121.     @4.4BSD)    TARGET=4.4bsd;;
  122.     @386BSD)    TARGET=386bsd;;
  123.     @FreeBSD)    TARGET=freebsd;;
  124.     @HP-UX)    TARGET=hpux;;
  125.     @*-Reno)    TARGET=reno;;
  126.     @AIX)    TARGET=aix32;;
  127.     @ULTRIX)    TARGET=ultrix;;
  128.     @)        echo "Sorry, no target specified and no uname command!";exit 1;;
  129.     *)        if [ -d /etc/saf ]; then
  130.             TARGET=svr4 SYS=SVR4
  131.         elif checkStrings /unix 'SCO UNIX'; then
  132.             TARGET=sco SYS="SCO"
  133.         elif checkStrings /unix 'INTERACTIVE UNIX'; then
  134.             TARGET=isc SYS="ISC"
  135.         else
  136.             echo "Sorry, I don't grok a $SYS system."
  137.             exit 1
  138.         fi
  139.         ;;
  140.     esac
  141.     identifyTarget $SYS
  142. fi
  143.  
  144. warnUnfinished()
  145. {
  146.     README=port/$1/README
  147.     if [ -f $README ]; then
  148.     echo "Warning, this port is incomplete; read $README for more information."
  149.     else
  150.     echo "Warning, This port is incomplete and there is no README file."
  151.     fi
  152. }
  153.  
  154. warnNoMakeDepend()
  155. {
  156.     echo "Warning, no make dependency support for this compilation environment."
  157. }
  158.  
  159. boom()
  160. {
  161.     echo "$@"
  162.     echo ""
  163.     echo "Unrecoverable error!  Once you've corrected the problem rerun this script."
  164.     exit 1
  165. }
  166.  
  167. case $TARGET in
  168. sgi|sgi-cc)
  169.     TARGET=sgi COMPILER=cc
  170.     ;;
  171. sun3|sun3-gcc|sun4|sun4-gcc)
  172.     TARGET=sun COMPILER=gcc
  173.     ;;
  174. solaris2-cc)
  175.     TARGET=solaris2 COMPILER=cc
  176.     warnNoMakeDepend
  177.     warnUnfinished $TARGET
  178.     ;;
  179. 4.4bsd*|hpux|hpux-gcc|reno*|ultrix*)
  180.     TARGET=`basename $TARGET -gcc` COMPILER=gcc
  181.     warnUnfinished $TARGET
  182.     ;;
  183. hpux-cc)
  184.     TARGET=hpux COMPILER=cc
  185.     warnUnfinished $TARGET
  186.     ;;
  187. *)
  188.     TARGET=`basename $TARGET -gcc` COMPILER=gcc
  189.     if [ ! -d port/$TARGET ]; then
  190.     echo "$TARGET: Unsupported system configuration."
  191.     exit 1
  192.     fi
  193.     ;;
  194. esac
  195.  
  196. #
  197. # Random system-dependent fixups that have to be
  198. # done before we go too far.
  199. #
  200. case $TARGET in
  201. linux)
  202.     ed()
  203.     {
  204.         sed -e '/^w$/d' -e '/^q$/d' > /tmp/ed.$$
  205.         $CP $2 /tmp/file.$$
  206.         sed -f /tmp/ed.$$ /tmp/file.$$ > $2
  207.         $RM /tmp/ed.$$ /tmp/file.$$
  208.     }
  209.     ;;
  210. ultrix)
  211.     # must use GNU make 'cuz standard make doesn't hack it
  212.     echo "Warning, prepending /usr/local/bin to PATH for GNU make."
  213.     test -d /usr/local/bin && PATH=/usr/local/bin:$PATH
  214.     ;;
  215. esac
  216.  
  217. #
  218. # Setup make-related files.
  219. #
  220. setupConfig()
  221. {
  222.     if [ -f port/$TARGET/Makefile.flexfax ]; then
  223.     M=port/$TARGET/Makefile.flexfax
  224.     elif [ -f port/$TARGET/Makefile ]; then
  225.     M=port/$TARGET/Makefile
  226.     else
  227.     boom "Help, no \"Makefile\" for building FlexFAX!"
  228.     fi
  229.     if [ -f port/$TARGET/defs.$COMPILER ]; then
  230.     D=port/$TARGET/defs.$COMPILER
  231.     elif [ -f port/$TARGET/defs ]; then
  232.     D=port/$TARGET/defs
  233.     else
  234.     boom "Help, no \"defs\" file for building FlexFAX!"
  235.     fi
  236.     echo "Installing $M as Makefile."
  237.     $RM Makefile; $CP $M Makefile
  238.     echo "Installing $D as defs."
  239.     $RM defs; $CP $D defs
  240. }
  241. getConfigTag()
  242. {
  243.     param=`grep "$1:" $2 | sed -e 's/.*:[     ]*\([^     ]*\).*/\1/'`
  244. }
  245.  
  246. echo "Setting up make-related files."
  247. if [ -f defs -a -f Makefile ]; then
  248.     getConfigTag TARGET defs;    target="$param"
  249.     getConfigTag COMPILER defs;    compiler="$param"
  250.     if [ "$target" != "$TARGET" -o "$compiler" != "$COMPILER" ]; then
  251.     echo "Replacing configuration for \"$target\" & \"$compiler\"."
  252.     setupConfig
  253.     else
  254.     #
  255.     # We should figure out if only localized changes were
  256.     # done to defs and/or Makefile and leave things unchanged;
  257.     # but for now that's too hard so we just cloberr things
  258.     # under the assumption that folks don't configure very
  259.     # often and doing something simpleminded can lead to problems.
  260.     #
  261.     echo "Updating configuration for \"$target\" & \"$compiler\"."
  262.     setupConfig
  263.     fi
  264. else
  265.     setupConfig
  266. fi
  267.  
  268. #
  269. # Verify that defs has correct C++ and C compiler definitions.
  270. #
  271. (cat defs; echo 'test: ${C++} ${CC}') | make -f - test >/dev/null 2>&1 || {
  272.     echo ""
  273.     echo "Something is wrong in the \"defs\" file, check the definitions of"
  274.     echo "the C++ and CC macros:"
  275.     echo ""
  276.     grep '^C++[     ]*=' defs; grep '^CC[     ]*=' defs
  277.     echo ""
  278.     boom "they do not appear to reflect the locations of your compilers."
  279. }
  280.  
  281. NewFixed=""
  282. if [ $COMPILER = gcc ]; then
  283.     GCCversion=`(cat defs; echo 'version: ${C++}; ${C++} -v') | \
  284.     make -f - version 2>&1 | \
  285.     sed -n -e '/version/s/.* //p'`
  286.     if expr "$GCCversion" \< 2.3.3 >/dev/null 2>&1; then
  287.     echo ""
  288.     echo "You appear to have gcc version $GCCversion; beware that you"
  289.     echo "may need to apply the patch in port/sun/GCC-PATCH before you"
  290.     echo "compile this software."
  291.     echo ""
  292.     else
  293.     # NB: defined in port.h below
  294.     NewFixed="yes"
  295.     fi
  296.     if [ $GCCversion = 2.5.8 -a $TARGET = sgi ]; then
  297.     echo ""
  298.     echo "Beware that you must build this version of gcc according to the"
  299.     echo "information given in port/sgi/README in order to get a working"
  300.     echo "system."
  301.     echo ""
  302.     fi
  303. fi
  304.  
  305. if [ $TARGET != "sgi" ]; then
  306.     echo "Setting up make dependency files."
  307.     #
  308.     # Setup null make dependency files so that we can include
  309.     # it w/o problem.  Some systems have conditional include
  310.     # support in their make, but others do not, so we use an
  311.     # unconditional include and setup everthing as null here
  312.     #
  313.     DEPEND="Makedepend        \
  314.     fax2ps/Makedepend    \
  315.     faxalter/Makedepend    \
  316.     faxcover/Makedepend    \
  317.     faxd/Makedepend        \
  318.     faxmail/Makedepend    \
  319.     faxrm/Makedepend    \
  320.     faxstat/Makedepend    \
  321.     iv/Makedepend        \
  322.     recvfax/Makedepend    \
  323.     sendfax/Makedepend    \
  324.     sgi2fax/Makedepend    \
  325.     util/Makedepend        \
  326.     man/Makedepend        \
  327.     doc/Makedepend        \
  328.     etc/Makedepend        \
  329.     relnotes/Makedepend    \
  330.     libtiff/Makedepend    \
  331.     port/$TARGET/Makedepend    \
  332.     "
  333.     $RM $DEPEND; tee $DEPEND </dev/null
  334.     editFile rules '/^sinclude/s//include/'
  335. fi
  336.  
  337. #
  338. # Install appropriate TIFF library Makefile: look first
  339. # in the port area, then for a Makefile that is part of
  340. # the standard TIFF distribution.  The priority is:
  341. #
  342. # port/<target>/Makefile.libtiff.<compiler>
  343. # port/<target>/Makefile.libtiff
  344. # port/generic/Makefile.libtiff.<compiler>
  345. # port/libtiff/Makefile.<target>-<compiler>
  346. # port/libtiff/Makefile.<target>
  347. # port/libtiff/Makefile.<compiler>
  348. #
  349. if [ -f port/$TARGET/Makefile.libtiff.$COMPILER ]; then
  350.     M=port/$TARGET/Makefile.libtiff.$COMPILER
  351. elif [ -f port/$TARGET/Makefile.libtiff ]; then
  352.     M=port/$TARGET/Makefile.libtiff
  353. elif [ -f port/generic/Makefile.libtiff.$COMPILER ]; then
  354.     M=port/generic/Makefile.libtiff.$COMPILER
  355. elif [ -f libtiff/Makefile.$TARGET-$COMPILER ]; then
  356.     M=libtiff/Makefile.$TARGET-$COMPILER
  357. elif [ -f libtiff/Makefile.$TARGET ]; then
  358.     M=libtiff/Makefile.$TARGET
  359. elif [ -f libtiff/Makefile.$COMPILER ]; then
  360.     M=libtiff/Makefile.$COMPILER
  361. else
  362.     boom "Can not locate Makefile for building the TIFF software."
  363. fi
  364. echo "Installing $M as libtiff/Makefile."
  365. $RM libtiff/Makefile; $CP $M libtiff/Makefile
  366.  
  367. #
  368. # Some makes can not deal with certain types of
  369. # whitespace-filled lines that occasionally creep
  370. # in--so purge anything strange before compiling.
  371. #
  372. badMakefiles=`grep -l '^    $' Makefile */Makefile`
  373. if [ "$badMakefiles" ]; then
  374.     #
  375.     # This bizarre stuff is used instead of just doing
  376.     # editFile $m '^<tab>$/s///' because some shells
  377.     # appear to convert the tab to a blank!
  378.     #
  379.     echo '/^    $/s///' | tr ' ' '\011' >/tmp/$$ed
  380.     echo w >>/tmp/$$ed; echo q >>/tmp/$$ed
  381.     echo "Fixing up bad make files:"
  382.     for m in $badMakefiles; do
  383.     echo "  $m"
  384.     chmod +w $m; cat /tmp/$$ed | ed - $m >/dev/null; chmod -w $m
  385.     done
  386.     $RM /tmp/$$ed
  387. fi
  388.  
  389. patchForBogusIncludeSyntax()
  390. {
  391.     echo "Warning, patching Makefile stuff to use bogus include syntax."
  392.     for i do
  393.     patchFile $i "g/^include/s/^include[  ]*\(.*\)$/.include <\1>/"
  394.     done
  395. }
  396.  
  397. patchForBogusSunPro()
  398. {
  399.     echo "Warning, patching $1 to use SunPro file.c++=.C syntax."
  400.     patchFile $1 "$2"
  401. }
  402.  
  403. patchShellScripts()
  404. {
  405.     shell=$1
  406.     for i in etc/faxaddmodem.sh etc/probemodem.sh util/notify.sh util/*stats.sh
  407.     do
  408.     echo "Warning, patching $i to use $shell"
  409.     patchFile $i "/^#! /s;/bin/sh;$shell;"
  410.     done
  411. }
  412.  
  413. case "$TARGET-$COMPILER" in
  414. 386bsd*|freebsd*|ultrix*|bsdi*)
  415.     patchShellScripts /bin/bash
  416.     ;;
  417. hpux*)
  418.     patchShellScripts /bin/ksh
  419.     ;;
  420. bsdi-gcc)
  421.     $RM port/$TARGET/stdio.h; $CP /usr/include/stdio.h port/$TARGET
  422.     editFile port/$TARGET/stdio.h '/static inline int/s//static int/'
  423.     ;;
  424. reno*|4.4bsd*)
  425.     patchForBogusIncludeSyntax Makefile rules */Makefile
  426.     ;;
  427. solaris2-cc)
  428.     #
  429.     # Yech, the SunPro C++ compiler has no option to force a source
  430.     # file w/ a .c++ suffix to be treated as C++ source code; instead one
  431.     # must specify file.c++=.C.  We patch the Makefiles with explicit
  432.     # construction rules to do this...
  433.     #
  434.     patchForBogusSunPro rules 'g/\\$</s//&=.C/'
  435.     patchForBogusSunPro iv/Makefile 'g/-c.*\\.c++$/s/.c++/&=.C/'
  436.     patchForBogusSunPro faxd/Makefile '/^[     ]*UUCPLock.c++$/s//&=.C/'
  437.     patchForBogusSunPro util/Makefile '/^[     ]*textfmt.c++$/s//&=.C/'
  438.     ;;
  439. esac
  440.  
  441. #
  442. # Figure out if certain system-specific interfaces are
  443. # supported.  We craft a port.h file that has external
  444. # declarations for missing routines that are required by
  445. # the system and modify defs to reflect which optional
  446. # interfaces are supported.
  447. #
  448.  
  449. EmitCPlusPlusPrologue()
  450. {
  451.     echo '/*'
  452.     echo ' * Warning, this file was automatically created by the configure script'
  453.     echo ' * DATE:    ' `date`
  454.     echo ' * TARGET:    ' $TARGET
  455.     if [ $COMPILER = gcc ]; then
  456.     echo ' * COMPILER:    ' $COMPILER $GCCversion
  457.     else
  458.     echo ' * COMPILER:    ' $COMPILER
  459.     fi
  460.     echo ' */'
  461.     echo "#ifndef $1"
  462.     echo '#ifdef __cplusplus'
  463.     echo 'extern "C" {'
  464.     echo '#endif'
  465. }
  466.  
  467. EmitCPlusPlusEpilogue()
  468. {
  469.     echo '#ifdef __cplusplus'
  470.     echo '}'
  471.     echo '#endif'
  472.     echo '#endif'
  473. }
  474.  
  475. #
  476. # Look for a function in one of the standard libraries.
  477. #
  478. CheckFunc()
  479. {
  480.     echo "extern int $1(); main(){$1();exit(0);}" >t.c
  481.     (echo DEPTH=.; cat defs; echo 't:; ${CCF} t.c') |\
  482.      make -f - t >/dev/null 2>&1
  483.     return
  484. }
  485.  
  486. #
  487. # Look for a function declaration in system include files.
  488. #
  489. AddFuncDecl()
  490. {
  491.     (echo "$2"; echo "... add function prototype for $1" 1>&2)
  492. }
  493. CheckForFuncDecl()
  494. {
  495.     f=$1; shift
  496.     (for i do
  497.     echo "#include \"$i\""
  498.      done)>t.c++
  499.     (echo DEPTH=.; cat defs; echo 't:; ${C++F} ${C++FILE} -E t.c++') |\
  500.      make -f - t 2>&1 |\
  501.      awk '{while($0~/[,(][ \t]*$/){printf"%s",$0;getline}print}' |\
  502.      grep "$f[ ]*(.*)" >/dev/null
  503.     return
  504. }
  505. CheckFuncDecl()
  506. {
  507.     f=$1; shift
  508.     decl=$1; shift
  509.     CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl"
  510. }
  511.  
  512. #
  513. # Look for a variable declaration in system include files.
  514. #
  515. CheckVarDecl()
  516. {
  517.     v=$1; shift
  518.     decl=$1; shift
  519.     (for i do
  520.     echo "#include \"$i\""
  521.      done)>t.c++
  522.     (echo DEPTH=.; cat defs; echo 't:; ${C++F} ${C++FILE} -E t.c++') |\
  523.      make -f - t 2>&1 |\
  524.      grep "$v" >/dev/null ||\
  525.     (echo "$decl"; echo "... add declaration $decl" 1>&2)
  526. }
  527.  
  528. #
  529. # Look for a #define in system include files.
  530. #
  531. AddDefine()
  532. {
  533.    echo '#ifndef' $1
  534.    echo '#define' "$2"
  535.    echo '#endif'
  536.    echo '... add #define for' "$1" 1>&2
  537. }
  538. CheckForDefine()
  539. {
  540.     def=$1; shift
  541.     (for i do
  542.     echo "#include \"$i\""
  543.      done
  544.      for i in "#ifdef $def" "FOUND" "#endif"; do
  545.     echo "$i"
  546.      done
  547.     )>t.c
  548.     (echo DEPTH=.; cat defs; echo 't:; ${CCF} -E t.c') |\
  549.      make -f - t 2>&1 |\
  550.      grep FOUND >/dev/null
  551.     return
  552. }
  553. CheckDefine()
  554. {
  555.     def=$1; shift
  556.     decl=$1; shift
  557.     CheckForDefine "$def" "$@" || AddDefine "$def" "$decl"
  558. }
  559.  
  560. #
  561. # Look for an include file.
  562. #
  563. CheckForIncludeFile()
  564. {
  565.     (for i do
  566.     echo "#include \"$i\""
  567.      done)>t.c++
  568.     (echo DEPTH=.; cat defs; echo 't:; ${C++F} ${C++FILE} -E t.c++') |\
  569.      make -f - t >/dev/null 2>&1
  570.     return
  571. }
  572.  
  573. CheckTermioFuncDecls()
  574. {
  575.     CheckFuncDecl cfsetospeed \
  576.     'extern int cfsetospeed(const struct termios*, speed_t);' $@
  577.     CheckFuncDecl cfsetispeed \
  578.     'extern int cfsetispeed(const struct termios*, speed_t);' $@
  579.     CheckFuncDecl tcgetattr 'extern int tcgetattr(int, struct termios*);' $@
  580.     CheckFuncDecl tcsetattr \
  581.     'extern int tcsetattr(int, int, const struct termios*);' $@
  582.     CheckFuncDecl tcsendbreak 'extern int tcsendbreak(int, int);' $@
  583.     CheckFuncDecl tcdrain 'extern int tcdrain(int);' $@
  584.     CheckFuncDecl tcflush 'extern int tcflush(int, int);' $@
  585.     CheckFuncDecl tcflow 'extern int tcflow(int, int);' $@
  586. }
  587.  
  588. JUNK="xport.h xtermios.h t.c t.c++ a.out"
  589. trap "$RM \$JUNK; exit 1" 1 2 15
  590.  
  591. $RM xport.h port.h xtermios.h termios.h a.out t t.c t.c++
  592.  
  593. CheckForIncludeFile termios.h || {
  594.     CheckForIncludeFile sys/termios.h || {
  595.     boom "Cannot locate termios.h or sys/termios.h."
  596.     }
  597.     echo "No termios.h found; creating one with necessary definitions."
  598.     (EmitCPlusPlusPrologue _TERMIOS_
  599.      echo '#include "sys/termios.h"'
  600.      CheckTermioFuncDecls sys/termios.h
  601.      EmitCPlusPlusEpilogue
  602.     )>xtermios.h
  603.     mv xtermios.h termios.h; chmod 444 termios.h
  604. }
  605.  
  606. echo "Creating port.h with necessary definitions."
  607.  
  608. (EmitCPlusPlusPrologue _PORT_
  609. test "$NewFixed" = "yes"    && echo '#define NEW_FIXED'
  610. fifoOpenMode="O_RDONLY"
  611. case $TARGET in
  612. solaris2)
  613.     echo "... enable Solaris 2.x workaround for FIFO select bug" 1>&2
  614.     echo '#define FIFOSELECTBUG'
  615.     ;;
  616. sgi)
  617.     # enable workarounds for IRIX 5.x kernel bugs
  618.     case "`uname -a | cut '-d ' -f3`" in
  619.     5.[012]*)
  620.     echo "... enable IRIX 5.x workarounds for FIFO and select bugs" 1>&2
  621.     echo '#define FIFOSELECTBUG'
  622.     echo '#define SGISELECTBUG'
  623.     ;;
  624.     esac
  625.     ;;
  626. sco|isc)
  627.     echo "... enable additional include files for TIOCGWINSZ" 1>&2
  628.     echo "#define CONFIG_WINSZHACK"
  629.     fifoOpenMode="O_RDWR"
  630.     ;;
  631. aix32|ultrix|hpux)
  632.     fifoOpenMode="O_RDWR"
  633.     ;;
  634. esac
  635. if [ "$fifoOpenMode" = "O_RDWR" ]; then
  636.     echo "... open FIFO files read+write to avoid select bug" 1>&2
  637. else
  638.     echo "... open FIFO files read-only" 1>&2
  639. fi
  640. echo "#define CONFIG_OPENFIFO $fifoOpenMode"
  641. CheckFuncDecl mkstemp 'extern int mkstemp(char *);' stdio.h unistd.h
  642. CheckFuncDecl strerror 'extern char* strerror(int);' string.h
  643. CheckFuncDecl strncasecmp \
  644.     'extern int strncasecmp(const char*, const char*, size_t);' string.h
  645. CheckFuncDecl strcasecmp \
  646.     'extern int strcasecmp(const char*, const char*);' string.h
  647. CheckFuncDecl strdup 'extern char* strdup(const char*);' string.h
  648. CheckFuncDecl memset 'extern void* memset(void*, int, size_t);' string.h
  649. CheckFuncDecl random 'extern long random(void);' math.h stdlib.h
  650. CheckFuncDecl floor 'extern double floor(double);' math.h
  651. CheckFuncDecl waitpid 'extern pid_t waitpid(pid_t, int *, int);' sys/wait.h
  652. CheckDefine _POSIX_OPEN_MAX '_POSIX_OPEN_MAX 16' limits.h
  653. CheckDefine howmany 'howmany(x, y)    (((x)+((y)-1))/(y))' sys/types.h
  654. CheckForFuncDecl sigvec signal.h || {
  655.     echo '#ifdef SV_INTERRUPT'
  656.     echo 'struct sigvec;'
  657.     AddFuncDecl sigvec \
  658.     'extern int sigvec(int, const struct sigvec*, struct sigvec*);'
  659.     echo '#endif'
  660. }
  661. CheckForFuncDecl sigaction signal.h || {
  662.     echo '#ifdef SA_NOCLDSTOP'
  663.     echo 'struct sigaction;'
  664.     AddFuncDecl sigaction \
  665.     'extern int sigaction(int, const struct sigaction*, struct sigaction*);'
  666.     echo '#endif'
  667. }
  668. CheckFuncDecl kill 'extern int kill(pid_t, int);' signal.h
  669. CheckFuncDecl close 'extern int close(int);' unistd.h
  670. CheckFuncDecl getuid 'extern uid_t getuid(void);' unistd.h
  671. CheckFuncDecl geteuid 'extern uid_t geteuid(void);' unistd.h
  672. CheckFuncDecl seteuid 'extern int seteuid(uid_t);' unistd.h
  673. CheckFuncDecl setegid 'extern int setegid(gid_t);' unistd.h
  674. CheckFuncDecl ftruncate 'extern int ftruncate(int, off_t);' unistd.h
  675. CheckFuncDecl getdtablesize 'extern int getdtablesize(void);' unistd.h
  676. #
  677. # unistd.h is where many people put it
  678. # sys/select.h is for USL-derived code
  679. # sys/time.h is for HP systems (sigh)
  680. #
  681. CheckForFuncDecl select unistd.h sys/select.h sys/time.h || {
  682.     echo 'struct fd_set;'
  683.     echo 'struct timeval;'
  684.     AddFuncDecl select \
  685.     'extern int select(int,struct fd_set*,struct fd_set*,struct fd_set*,struct timeval*);'
  686. }
  687. CheckFuncDecl unlink 'extern int unlink(const char*);' unistd.h
  688. CheckFuncDecl read 'extern int read(int, const void*, unsigned int);' unistd.h
  689. CheckFuncDecl ioctl 'extern int ioctl(int, int, ...);' unistd.h sys/ioctl.h
  690. CheckFunc fchown && {
  691.     echo '#define HAS_FCHOWN 1'
  692.     echo "... configure use of fchown" 1>&2
  693.     CheckFuncDecl fchown 'extern int fchown(int, uid_t, gid_t);' unistd.h
  694. }
  695. CheckFuncDecl gethostname 'extern int gethostname(char*, int);' unistd.h osfcn.h
  696. CheckFuncDecl malloc 'extern void* malloc(size_t);' stdlib.h
  697. CheckFuncDecl realloc 'extern void* realloc(void*, size_t);' stdlib.h
  698. CheckFuncDecl free 'extern void free(void*);' stdlib.h
  699. CheckFuncDecl strtoul \
  700.     'extern unsigned long strtoul(const char*, char**, int);' stdlib.h
  701. CheckFuncDecl cuserid 'extern char* cuserid(char*);' stdio.h
  702. #
  703. # unistd.h is for sco3.2v4.[0-2]
  704. #
  705. CheckFuncDecl getopt \
  706.     'extern int getopt(int, char* const*, const char*);' stdlib.h unistd.h
  707. CheckFuncDecl isatty 'extern int isatty(int);' stdlib.h unistd.h
  708. CheckVarDecl 'char.*optarg' 'extern char* optarg;' stdlib.h
  709. CheckVarDecl 'int.*opterr' 'extern int opterr;' stdlib.h
  710. CheckVarDecl 'int.*optind' 'extern int optind;' stdlib.h
  711. CheckFuncDecl mktemp 'extern char* mktemp(char*);' stdio.h unistd.h
  712. CheckFuncDecl tempnam 'extern char* tempnam(const char*, const char*);' stdio.h
  713. CheckFuncDecl popen 'extern FILE* popen(const char *, const char *);' stdio.h
  714. CheckFuncDecl pclose 'extern int pclose(FILE*);' stdio.h
  715. CheckFuncDecl fdopen 'extern FILE* fdopen(int, const char*);' stdio.h
  716. CheckForDefine fileno stdio.h || {
  717.     CheckFuncDecl fileno 'extern int fileno(FILE*);' stdio.h
  718. }
  719. CheckFuncDecl opendir 'extern DIR* opendir(const char*);' dirent.h
  720. CheckFuncDecl syslog 'extern void syslog(int, const char*, ...);' syslog.h
  721. CheckForFuncDecl vsyslog syslog.h || {
  722.     echo '#include <stdarg.h>'
  723.     AddFuncDecl vsyslog 'extern void vsyslog(int, const char*, va_list);'
  724. }
  725. CheckFuncDecl closelog 'extern void closelog(void);' syslog.h
  726. CheckFuncDecl openlog 'extern void openlog(const char*, int, int);' syslog.h
  727. CheckFunc fchmod && {
  728.     echo '#define HAS_FCHMOD 1'
  729.     echo "... configure use of fchmod" 1>&2
  730.     CheckFuncDecl fchmod 'extern int fchmod(int, mode_t);' \
  731.     unistd.h libc.h osfcn.h sys/stat.h
  732. }
  733. if [ "$TARGET-$COMPILER" = "solaris2-cc" ]; then
  734.     #
  735.     # SunPro pre-processor leaves comments in!  This messes up
  736.     # the scheme used by CheckFuncDecl 'cuz time.h has a comment
  737.     # in it that includes "gettimeofday(2)".  Sigh...
  738.     #
  739.     AddFuncDecl gettimeofday \
  740.     'extern int gettimeofday(struct timeval*, struct timezone*);'
  741. else
  742.     CheckForFuncDecl gettimeofday sys/time.h || {
  743.     echo 'struct timezone;'
  744.     echo 'struct timeval;'
  745.     AddFuncDecl gettimeofday \
  746.         'extern int gettimeofday(struct timeval*, struct timezone*);'
  747.     }
  748. fi
  749. CheckForFuncDecl strftime time.h || {
  750.     echo 'struct tm;'
  751.     AddFuncDecl strftime \
  752.     'extern size_t strftime(char*,size_t,const char*,const struct tm*);'
  753. }
  754. CheckForFuncDecl localtime time.h || {
  755.     echo 'struct tm;'
  756.     AddFuncDecl localtime 'struct tm* localtime(const time_t* clock);'
  757. }
  758. CheckForFuncDecl setitimer sys/time.h || {
  759.     echo '#ifdef ITIMER_REAL'
  760.     echo 'struct itimerval;'
  761.     AddFuncDecl setitimer \
  762.     'extern int setitimer(int,struct itimerval*,struct itimerval*);'
  763.     echo '#endif'
  764. }
  765. CheckFuncDecl endpwent 'extern void endpwent(void);' pwd.h
  766. CheckFuncDecl getpwnam 'extern struct passwd* getpwnam(const char*);' pwd.h
  767. if [ "$TARGET" != "reno" ]; then
  768.     CheckFuncDecl toupper 'extern int toupper(int);' ctype.h
  769.     CheckFuncDecl tolower 'extern int tolower(int);' ctype.h
  770. fi
  771. CheckFuncDecl getpeername 'extern int getpeername(int,void*,int*);' sys/socket.h
  772. CheckFuncDecl socket 'extern int socket(int, int, int);' sys/socket.h
  773. CheckFuncDecl connect 'extern int connect(int, const void*, int);' sys/socket.h
  774. CheckForFuncDecl gethostbyname netdb.h || {
  775.     echo 'struct hostent;'
  776.     AddFuncDecl gethostbyname \
  777.     'extern struct hostent* gethostbyname(const char*);'
  778. }
  779. CheckForFuncDecl gethostbyaddr netdb.h || {
  780.     echo 'struct hostent;'
  781.     AddFuncDecl gethostbyaddr \
  782.     'extern struct hostent* gethostbyaddr(const void*, int, int);'
  783. }
  784. CheckForFuncDecl getservbyname netdb.h || {
  785.     echo 'struct servent;'
  786.     AddFuncDecl getservbyname \
  787.     'extern struct servent*    getservbyname(const char*, const char*);'
  788. }
  789. CheckForDefine LOCK_SH sys/file.h || {
  790.     AddDefine LOCK_SH 'LOCK_SH    1    /* shared lock */'
  791.     AddDefine LOCK_EX 'LOCK_EX    2    /* exclusive lock */'
  792.     AddDefine LOCK_NB 'LOCK_NB    4    /* dont block when locking */'
  793.     AddDefine LOCK_UN 'LOCK_UN    8    /* unlock */'
  794. }
  795. CheckFuncDecl flock 'extern int flock(int, int);' sys/file.h
  796. CheckTermioFuncDecls termios.h
  797. EmitCPlusPlusEpilogue
  798. )>xport.h
  799. mv xport.h port.h; chmod 444 port.h
  800. $RM $JUNK
  801.  
  802. #
  803. # Figure out which brand of echo we have and define
  804. # prompt and print shell functions accordingly.
  805. #
  806. if [ `echo foo\\\c`@ = "foo@" ]; then
  807.     prompt()
  808.     {
  809.        echo "$* \\c"
  810.     }
  811. elif [ "`echo -n foo`@" = "foo@" ]; then
  812.     prompt()
  813.     {
  814.        echo -n "$* "
  815.     }
  816. else
  817.     prompt()
  818.     {
  819.     echo "$*"
  820.     }
  821. fi
  822.  
  823. #
  824. # Prompt the user for a string that can not be null.
  825. #
  826. promptForNonNullStringParameter()
  827. {
  828.     x=""
  829.     while [ -z "$x" ]; do
  830.     prompt "$2 [$1]?"; read x
  831.     if [ "$x" ]; then
  832.         # strip leading and trailing white space
  833.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  834.     else
  835.         x="$1"
  836.     fi
  837.     done
  838.     param="$x"
  839. }
  840.  
  841. #
  842. # Prompt the user for a numeric value.
  843. #
  844. promptForNumericParameter()
  845. {
  846.     x=""
  847.     while [ -z "$x" ]; do
  848.     prompt "$2 [$1]?"; read x
  849.     if [ "$x" ]; then
  850.         # strip leading and trailing white space
  851.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  852.         match=`expr "$x" : "\([0-9]*\)"`
  853.         if [ "$match" != "$x" ]; then
  854.         echo ""
  855.         echo "This must be entirely numeric; please correct it."
  856.         echo ""
  857.         x="";
  858.         fi
  859.     else
  860.         x="$1"
  861.     fi
  862.     done
  863.     param="$x"
  864. }
  865.  
  866. promptForLockType()
  867. {
  868.     x=""
  869.     while [ -z "$x" ]; do
  870.     prompt "Type of uucp lock files [$UUCP_LOCKTYPE]?"; read x
  871.     if [ "$x" ]; then
  872.         # strip leading and trailing white space
  873.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  874.         if [ "$x" != "ascii" -a "$x" != "binary" ]; then
  875. cat <<EOF
  876.  
  877. "$x" is not a uucp lock type; choose either "ascii"
  878. for System V-style lock files with ascii contents or
  879. "binary" for BSD-style lock files with binary contents.
  880. EOF
  881.         x=""
  882.         fi
  883.     else
  884.         x="$UUCP_LOCKTYPE"
  885.     fi
  886.     done
  887.     UUCP_LOCKTYPE="$x"
  888. }
  889.  
  890. promptForImagerPackage()
  891. {
  892.     x=""
  893.     while [ -z "$x" ]; do
  894.     prompt "PostScript imager package [$PSPACKAGE]?"; read x
  895.     if [ "$x" ]; then
  896.         # strip leading and trailing white space
  897.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  898.         case "$x" in
  899.         [dD]ps|DPS)            x="dps";;
  900.         [gG]s|[gG]host[sS]cript)    x="gs";;
  901.         *)
  902. cat <<EOF
  903.  
  904. "$x" is not a PostScript imager package; choose either "dps"
  905. for Display PostScript on a Silicon Graphics machine or "gs"
  906. for the freely available Ghostscript package.
  907. EOF
  908.         x="";;
  909.         esac
  910.     else
  911.         x="$PSPACKAGE"
  912.     fi
  913.     done
  914.     PSPACKAGE="$x"
  915. }
  916.  
  917. promptForPageSize()
  918. {
  919.     x=""
  920.     while [ -z "$x" ]; do
  921.     prompt "Default page size [$PAGESIZE]?"; read x
  922.     if [ "$x" ]; then
  923.         # strip leading and trailing white space
  924.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  925.         # search pagesizes file for an entry
  926.         y=`sed -e '/^#/d' $1 | grep -i "$x" | sed -e 's/    .*//;q'`
  927.         if [ -z "$y" ]; then
  928.         cat<<EOF
  929.  
  930. "$x" is not a known page size; the following are known page sizes:
  931.  
  932. Name            Abbrev    Width    Height    Width    Height    Top    Left
  933. EOF
  934.         sed -e '/^#/d' -e '/^default/d' $1
  935.         echo ""
  936.         x=""
  937.         else
  938.         x="$y"
  939.         fi
  940.     else
  941.         x="$PAGESIZE"
  942.     fi
  943.     done
  944.     PAGESIZE="$x"
  945. }
  946.  
  947. #
  948. # Prompt the user for a numeric value.
  949. #
  950. promptForVRes()
  951. {
  952.     x=""
  953.     while [ -z "$x" ]; do
  954.     prompt "Default vertical res (lpi) [$FAX_DEFVRES]?"; read x
  955.     if [ "$x" ]; then
  956.         # strip leading and trailing white space
  957.         x=`echo "$x" | sed -e 's/^[     ]*//' -e 's/[     ]*$//'`
  958.         case "$x" in
  959.         98|low|med*)    x="98";;
  960.         196|high|fine)    x="196";;
  961.         *)
  962. cat <<EOF
  963.  
  964. "$x" is not a valid vertical resolution; choose either "98" lines/inch
  965. (low resolution) or "196" lines/inch (often called fine resolution).
  966.  
  967. EOF
  968.         x="";;
  969.         esac
  970.     else
  971.         x="$FAX_DEFVRES"
  972.     fi
  973.     done
  974.     FAX_DEFVRES="$x"
  975. }
  976.  
  977. getParameter()
  978. {
  979.     param=`grep "^$1[     ]*=" $2 | \
  980.     sed -e 's/#.*//' -e 's/.*=[     ]*//' -e 's/[     ]*$//'`
  981. }
  982. getPageSizeInfo()
  983. {
  984.     pat=`grep '^default' $1 | \
  985.     sed -e 's/default[     ]*//' -e 's/[     ][     ]*/\[     \]*/g'`
  986.     param=`grep "$pat" $1 | sed -e 's/    .*//;q'`
  987. }
  988. getUtilParameter()
  989. {
  990.     param=`grep "$1" $2 | sed -e "s/.*$1[     ]*\([^     ]*\).*/\1/"`
  991. }
  992.  
  993. getProtoParameters()
  994. {
  995.     file=$1;
  996.     getParameter BIN $file;             FAX_BINDIR="$param"
  997.     getParameter LIBDATA $file;         FAX_LIBDATA="$param"
  998.     getParameter LIBEXEC $file;         FAX_LIBEXEC="$param"
  999.     getParameter SPOOL $file;             FAX_SPOOLDIR="$param"
  1000.     getParameter USRETC $file;            USRETC="$param"
  1001.     getParameter MAN $file;             MAN="$param"
  1002.     getParameter DOC $file;             DOC="$param"
  1003.     getParameter PSPACKAGE $file;        PSPACKAGE="$param"
  1004.     getParameter AFMDIR $file;            AFMDIR="$param"
  1005.     getParameter UUCP_LOCKTYPE $file;        UUCP_LOCKTYPE="$param"
  1006.     getParameter UUCP_LOCKMODE $file;        UUCP_LOCKMODE="$param"
  1007.     getParameter UUCP_LOCKDIR $file;        UUCP_LOCKDIR="$param"
  1008.     getParameter PSIMAGER $file;        PSIMAGER="$param"
  1009.     getParameter SENDMAIL $file;        SENDMAIL="$param"
  1010.     getPageSizeInfo util/pagesizes;        PAGESIZE="$param"
  1011.     getUtilParameter FAX_DEFVRES util/config.h;    FAX_DEFVRES="$param"
  1012. }
  1013.  
  1014. saveProtoParameters()
  1015. {
  1016.     protoFAX_BINDIR="$FAX_BINDIR"
  1017.     protoFAX_LIBDATA="$FAX_LIBDATA"
  1018.     protoFAX_LIBEXEC="$FAX_LIBEXEC"
  1019.     protoFAX_LIBFILTER="$FAX_LIBFILTER"
  1020.     protoFAX_SPOOLDIR="$FAX_SPOOLDIR"
  1021.     protoUSRETC="$USRETC"
  1022.     protoMAN="$MAN"
  1023.     protoDOC="$DOC"
  1024.     protoPSPACKAGE="$PSPACKAGE"
  1025.     protoAFMDIR="$AFMDIR"
  1026.     protoUUCP_LOCKTYPE="$UUCP_LOCKTYPE"
  1027.     protoUUCP_LOCKMODE="$UUCP_LOCKMODE"
  1028.     protoUUCP_LOCKDIR="$UUCP_LOCKDIR"
  1029.     protoSENDMAIL="$SENDMAIL"
  1030.     protoPAGESIZE="$PAGESIZE"
  1031.     protoFAX_DEFVRES="$FAX_DEFVRES"
  1032. }
  1033.  
  1034. printConfig()
  1035. {
  1036.     cat<<EOF
  1037.  
  1038. FlexFAX configuration parameters are:
  1039.  
  1040. Directory for applications:    $FAX_BINDIR
  1041. Directory for lib data files:    $FAX_LIBDATA
  1042. Directory for lib executables:    $FAX_LIBEXEC
  1043. Directory for servers:        $USRETC
  1044. Directory for manual pages:    $MAN
  1045. Directory for documentation:    $DOC
  1046. Directory for spooling:        $FAX_SPOOLDIR
  1047. Type of uucp lock files:    $UUCP_LOCKTYPE
  1048. Directory for uucp lock files:    $UUCP_LOCKDIR
  1049. Mode for uucp lock files:    $UUCP_LOCKMODE
  1050. PostScript imager packaage:    $PSPACKAGE
  1051. PostScript imager program:    $PSIMAGER
  1052. Default page size:        $PAGESIZE
  1053. Default vertical res (lpi):    $FAX_DEFVRES
  1054. Directory for font metrics:    $AFMDIR
  1055. Location of sendmail program:    $SENDMAIL
  1056.  
  1057. EOF
  1058. }
  1059.  
  1060. bitchExecutable()
  1061. {
  1062.     echo ""
  1063.     echo "Warning, $1 does not seem to be an executable program;"
  1064.     echo "you'll need to correct this before starting up the fax server."
  1065. }
  1066.  
  1067. checkForExecutable()
  1068. {
  1069.     test -x $1 || bitchExecutable $1
  1070. }
  1071.  
  1072. bitchDirectory()
  1073. {
  1074.     echo ""
  1075.     echo "Warning, $1 does not seem to be a directory;"; shift
  1076.     for i do
  1077.     echo "$i";
  1078.     done
  1079. }
  1080.  
  1081. checkDirectory()
  1082. {
  1083.     dir=$1; shift
  1084.     test -d $dir || bitchDirectory $dir "$@"
  1085. }
  1086.  
  1087. checkFont()
  1088. {
  1089.     test -r $AFMDIR/$1 -o -r $AFMDIR/$1.afm
  1090.     return
  1091. }
  1092.  
  1093. checkAFMSetup()
  1094. {
  1095.     if [ -d $AFMDIR ]; then
  1096.     # check for minimal font metrics required by textfmt
  1097.     checkFont Courier || cat<<EOF
  1098.  
  1099. Warning, no font metric information was found for the Courier font
  1100. in the directory $AFMDIR.  This means that text formatting
  1101. will not look right.  You need either to correct the AFMDIR parameter
  1102. in the defs file and/or install the font metrics for use with this
  1103. software (see the README file).
  1104. EOF
  1105.     checkFont Courier-Bold || cat<<EOF
  1106.  
  1107. Warning, no font metric information was found for the Courier-Bold font
  1108. in the directory $AFMDIR.  This means that the default handling
  1109. of ASCII text will fail because the typerules file converts text to
  1110. PostScript using this font.  You need to either correct the AFMDIR
  1111. definition in the defs file, install the font metrics for use with this
  1112. software (see the README file), or alter the typerules file to use a font
  1113. for which there are font metrics.
  1114. EOF
  1115.     else
  1116.     bitchDirectory $AFMDIR \
  1117. "this means that only a crummy builtin font will be available for imaging text."
  1118.     fi
  1119. }
  1120.  
  1121. checkPSImagerSetup()
  1122. {
  1123.     if test -x $PSIMAGER; then
  1124.     if [ "$PSPACKAGE" = "gs" ]; then
  1125.         # verify Ghostscript was linked with the tiffg3 device driver
  1126.         ($PSIMAGER -sDEVICE=tiffg3 </dev/null >/dev/null 2>&1) || cat<<EOF
  1127.  
  1128. Warning, the PostScript imaging program $PSIMAGER does not appear to be
  1129. to be configured with the tiffg3 device driver.  This is necessary for the
  1130. fax software to operate correctly.  See the README file for information
  1131. on building Ghostscript with the necessary TIFF driver.
  1132. EOF
  1133.     fi
  1134.     else
  1135.     bitchExecutable $PSIMAGER
  1136.     fi
  1137. }
  1138.  
  1139. #
  1140. # Setup general configuration parameters.
  1141. #
  1142. getProtoParameters defs
  1143. saveProtoParameters
  1144.  
  1145. # convert uucp lock type to something understandable
  1146. case "$UUCP_LOCKTYPE" in
  1147. 1) UUCP_LOCKTYPE="binary";;
  1148. *) UUCP_LOCKTYPE="ascii";;    # default
  1149. esac
  1150.  
  1151. ok=skip
  1152. while [ "$ok" != "" -a "$ok" != "y" -a "$ok" != "yes" ]; do
  1153.     if [ "$ok" != "skip" ]; then
  1154.     promptForNonNullStringParameter "$FAX_BINDIR" \
  1155.         "Directory to install applications";    FAX_BINDIR="$param"
  1156.     promptForNonNullStringParameter "$FAX_LIBDATA" \
  1157.         "Directory to install library data files";    FAX_LIBDATA="$param"
  1158.     promptForNonNullStringParameter "$FAX_LIBEXEC" \
  1159.         "Directory to install library executables";    FAX_LIBEXEC="$param"
  1160.     promptForNonNullStringParameter "$USRETC" \
  1161.         "Directory to install server programs";    USRETC="$param"
  1162.     promptForNonNullStringParameter "$MAN" \
  1163.         "Directory to install manual pages";    MAN="$param"
  1164.     promptForNonNullStringParameter "$DOC" \
  1165.         "Directory to install documentation";    DOC="$param"
  1166.     promptForNonNullStringParameter "$FAX_SPOOLDIR" \
  1167.         "Directory to setup server spooling area";    FAX_SPOOLDIR="$param"
  1168.     promptForLockType;
  1169.     promptForNonNullStringParameter "$UUCP_LOCKDIR" \
  1170.         "Directory for uucp lock files";        UUCP_LOCKDIR="$param"
  1171.     promptForNumericParameter "$UUCP_LOCKMODE" \
  1172.         "Protection mode for uucp lock files";    UUCP_LOCKMODE=$param;
  1173.     promptForImagerPackage;
  1174.     promptForNonNullStringParameter "$PSIMAGER" \
  1175.         "PostScript imager program";        PSIMAGER="$param"
  1176.     promptForPageSize util/pagesizes;
  1177.     promptForVRes;
  1178.     promptForNonNullStringParameter "$AFMDIR" \
  1179.         "Directory to find Adobe font metrics";    AFMDIR="$param"
  1180.     promptForNonNullStringParameter "$SENDMAIL" \
  1181.         "Location of sendmail program";        SENDMAIL="$param"
  1182.     fi
  1183.     checkDirectory $USRETC \
  1184. "this must be fixed before doing a make install of faxd and faxd.recv."
  1185.     checkAFMSetup
  1186.     checkPSImagerSetup
  1187.     checkForExecutable $SENDMAIL
  1188.     # make sure UUCP_LOCKMODE is an octal number
  1189.     if [ "`expr "$UUCP_LOCKMODE" : '\(.\)'`" != "0" ]; then
  1190.     UUCP_LOCKMODE="0${UUCP_LOCKMODE}"
  1191.     fi
  1192.     printConfig; prompt "Are these ok [yes]?"; read ok
  1193. done
  1194.  
  1195. # convert uucp lock type back to a #define
  1196. case "$UUCP_LOCKTYPE" in
  1197. ascii)    UUCP_LOCKTYPE=0;;
  1198. binary)    UUCP_LOCKTYPE=1;;
  1199. *)    boom "Help, uucp lock type is \"$UUCP_LOCKTYPE\"; shouldn't happen!";;
  1200. esac
  1201.  
  1202. echo ""
  1203.  
  1204. #
  1205. # defs include file for all Makefiles
  1206. #
  1207. if [    "$FAX_BINDIR"    != "$protoFAX_BINDIR"    \
  1208.      -o "$FAX_LIBDATA"    != "$protoFAX_LIBDATA"    \
  1209.      -o "$FAX_LIBEXEC"    != "$protoFAX_LIBEXEC"    \
  1210.      -o "$FAX_SPOOLDIR"    != "$protoFAX_SPOOLDIR"    \
  1211.      -o "$USRETC"    != "$protoUSRETC"    \
  1212.      -o "$MAN"        != "$protoMAN"        \
  1213.      -o "$DOC"        != "$protoDOC"        \
  1214.      -o "$AFMDIR"    != "$protoAFMDIR"    \
  1215.      -o "$UUCP_LOCKTYPE" != "$protoUUCP_LOCKTYPE" \
  1216.      -o "$UUCP_LOCKMODE" != "$protoUUCP_LOCKMODE" \
  1217.      -o "$UUCP_LOCKDIR"    != "$protoUUCP_LOCKDIR" \
  1218.      -o "$SENDMAIL"    != "$protoSENDMAIL" \
  1219. ]; then
  1220.     prompt "Set config parameters in the defs file [yes]?"; read x
  1221.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1222.     editFile defs \
  1223.         "/^BIN[     ]*=/s;=[^#]*;=${FAX_BINDIR};" \
  1224.         "/^LIBDATA[     ]*=/s;=[^#]*;=${FAX_LIBDATA};" \
  1225.         "/^LIBEXEC[     ]*=/s;=[^#]*;=${FAX_LIBEXEC};" \
  1226.         "/^SPOOL[     ]*=/s;=[^#]*;=${FAX_SPOOLDIR};" \
  1227.         "/^USRETC[     ]*=/s;=[^#]*;=${USRETC};" \
  1228.         "/^MAN[     ]*=/s;=[^#]*;=${MAN};" \
  1229.         "/^DOC[     ]*=/s;=[^#]*;=${DOC};" \
  1230.         "/^AFMDIR[     ]*=/s;=[^#]*;=${AFMDIR};" \
  1231.         "/^UUCP_LOCKTYPE[     ]*=/s;=[^#]*;=${UUCP_LOCKTYPE};" \
  1232.         "/^UUCP_LOCKMODE[     ]*=/s;=[^#]*;=${UUCP_LOCKMODE};" \
  1233.         "/^UUCP_LOCKDIR[     ]*=/s;=[^#]*;=${UUCP_LOCKDIR};" \
  1234.         "/^SENDMAIL[     ]*=/s;=[^#]*;=${SENDMAIL};"
  1235.     fi
  1236. fi
  1237.  
  1238. #
  1239. # util/config.h has definitions included by all source code.
  1240. #
  1241. getHParameter()
  1242. {
  1243.     param=`grep "$1" $2 | sed -e 's/.*"\(.*\)".*/\1/'`
  1244. }
  1245. f=util/config.h
  1246. getHParameter FAX_SPOOLDIR $f;    protoFAX_SPOOLDIR="$param"
  1247. getHParameter FAX_LIBDATA $f;    protoFAX_LIBDATA="$param"
  1248. getHParameter FAX_LIBEXEC $f;    protoFAX_LIBEXEC="$param"
  1249. getUtilParameter FAX_DEFVRES $f; protoFAX_DEFVRES="$param"
  1250. if [    "$FAX_LIBDATA"    != "$protoFAX_LIBDATA"    \
  1251.      -o "$FAX_LIBEXEC"    != "$protoFAX_LIBEXEC"    \
  1252.      -o "$FAX_SPOOLDIR"    != "$protoFAX_SPOOLDIR"    \
  1253.      -o "$FAX_DEFVRES"    != "$protoFAX_DEFVRES"    \
  1254. ]; then
  1255.     prompt "Set config parameters in $f [yes]?"; read x
  1256.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1257.     editFile $f \
  1258.         "/FAX_LIBDATA/s;${protoFAX_LIBDATA};${FAX_LIBDATA};" \
  1259.         "/FAX_LIBEXEC/s;${protoFAX_LIBEXEC};${FAX_LIBEXEC};" \
  1260.         "/FAX_SPOOLDIR/s;${protoFAX_SPOOLDIR};${FAX_SPOOLDIR};" \
  1261.         "/FAX_DEFVRES/s;${protoFAX_DEFVRES};${FAX_DEFVRES};"
  1262.     fi
  1263. fi
  1264.  
  1265. #
  1266. # etc/faxaddmodem.sh is the modem installation and configuration
  1267. # script; it has server-related definitions built into it.
  1268. #
  1269. f=etc/faxaddmodem.sh
  1270. quit=$FAX_BINDIR/faxquit
  1271. getParameter SPOOL $f;        protoFAX_SPOOLDIR="$param"
  1272. getParameter SERVERDIR $f;    protoUSRETC="$param"
  1273. getParameter LOCKDIR $f;    protoUUCP_LOCKDIR="$param"
  1274. getParameter QUIT $f;        protoQUIT="$param"
  1275.     getParameter FAXUSER defs;    PROTOUID="$param"
  1276. getParameter PROTOUID $f;    protoPROTOUID="$param"
  1277.     getParameter FAXGROUP defs;    PROTOGID="$param"
  1278. getParameter PROTOGID $f;    protoPROTOGID="$param"
  1279. if [    "$FAX_SPOOLDIR"    != "$protoFAX_SPOOLDIR" \
  1280.      -o "$PROTOUID"    != "$protoPROTOUID" \
  1281.      -o "$PROTOGID"    != "$protoPROTOGID" \
  1282.      -o "$USRETC"    != "$protoUSRETC" \
  1283.      -o "$UUCP_LOCKDIR"    != "$protoUUCP_LOCKDIR" \
  1284.      -o "$quit"        != "$protoQUIT" \
  1285. ]; then
  1286.     prompt "Set config parameters in $f [yes]?"; read x
  1287.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1288.     editFile $f \
  1289.         "/^SPOOL=/s;${protoFAX_SPOOLDIR};${FAX_SPOOLDIR};" \
  1290.         "/^PROTOUID=/s;${protoPROTOUID};${PROTOUID};" \
  1291.         "/^PROTOGID=/s;${protoPROTOGID};${PROTOGID};" \
  1292.         "/^SERVERDIR=/s;${protoUSRETC};${USRETC};" \
  1293.         "/^LOCKDIR=/s;${protoUUCP_LOCKDIR};${UUCP_LOCKDIR};" \
  1294.         "/^QUIT=/s;=.*/faxquit;=${FAX_BINDIR}/faxquit;"
  1295.     fi
  1296. fi
  1297.  
  1298. #
  1299. # etc/probemodem.sh is a modem debugging script;
  1300. # it has server-related definitions built into it.
  1301. #
  1302. f=etc/probemodem.sh
  1303. getParameter SPOOL $f;        protoFAX_SPOOLDIR="$param"
  1304. getParameter LOCKDIR $f;    protoUUCP_LOCKDIR="$param"
  1305. if [    "$FAX_SPOOLDIR"    != "$protoFAX_SPOOLDIR" \
  1306.      -o "$UUCP_LOCKDIR"    != "$protoUUCP_LOCKDIR" \
  1307. ]; then
  1308.     prompt "Set config parameters in $f [yes]?"; read x
  1309.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1310.     editFile $f \
  1311.         "/^SPOOL=/s;${protoFAX_SPOOLDIR};${FAX_SPOOLDIR};" \
  1312.         "/^LOCKDIR=/s;${protoUUCP_LOCKDIR};${UUCP_LOCKDIR};"
  1313.     fi
  1314. fi
  1315.  
  1316. #
  1317. # util/ps2fax.*.sh is the shell script that invokes the
  1318. # PostScript imager; it has the location of the imager
  1319. #
  1320. f=util/ps2fax.$PSPACKAGE.sh
  1321. getParameter PS $f
  1322. if [ "$PSIMAGER" != "$param" ]; then
  1323.     prompt "Set config parameters in $f [yes]?"; read x
  1324.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1325.     editFile $f "/^PS=/s;${param};${PSIMAGER};"
  1326.     fi
  1327. fi
  1328.  
  1329. #
  1330. # Several scripts are aware of the location of the spooling
  1331. # area and (possibly) of the mailer.
  1332. #
  1333. # util/faxrcvd.sh    for anonymous received facsimile
  1334. # util/pollrcvd.sh    for polled received facsimile
  1335. # util/notify.sh    for server notification of events
  1336. # util/xferstats.sh    for transmit statistics
  1337. # util/recvstats.sh    for receive statistics
  1338. # util/faxcron.sh    for cleaning up the spooling area
  1339. #
  1340. for f in util/faxrcvd.sh util/pollrcvd.sh util/notify.sh
  1341. do
  1342.     getParameter SPOOL $f;    protoSPOOL="$param"
  1343.     getParameter SENDMAIL $f;    protoSENDMAIL="$param"
  1344.     if [   "$FAX_SPOOLDIR"    != "$protoSPOOL" \
  1345.     -o "$SENDMAIL"    != "$protoSENDMAIL" \
  1346.     ]; then
  1347.     prompt "Set config parameters in $f [yes]? "; read x
  1348.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1349.         editFile $f \
  1350.         "/^SENDMAIL=/s;${protoSENDMAIL};${SENDMAIL};" \
  1351.         "/^SPOOL=/s;${protoFAX_SPOOLDIR};${FAX_SPOOLDIR};"
  1352.     fi
  1353.     fi
  1354. done
  1355.  
  1356. for f in util/*stats.sh util/faxcron.sh
  1357. do
  1358.     getParameter SPOOL $f;    protoSPOOL="$param"
  1359.     if [   "$FAX_SPOOLDIR"    != "$protoSPOOL" ]; then
  1360.     prompt "Set config parameters in $f [yes]? "; read x
  1361.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1362.         editFile $f \
  1363.         "/^SPOOL=/s;${protoFAX_SPOOLDIR};${FAX_SPOOLDIR};"
  1364.     fi
  1365.     fi
  1366. done
  1367.  
  1368. f=util/pagesizes
  1369. if [ "$PAGESIZE" != "$protoPAGESIZE" ]; then
  1370.     prompt "Set config parameter in $f [yes]? "; read x
  1371.     if [ -z "$x" -o "$x" = "y" -o "$x" = "yes" ]; then
  1372.     newDefault=`grep "$PAGESIZE" $f | sed -e 's/[^    ]*/default/;q'`
  1373.     editFile $f "/^default/s/.*/$newDefault/"
  1374.     fi
  1375. fi
  1376. echo "Done."
  1377. exit 0
  1378.